#include "Login.h"
#include "ui_Login.h"
#include"MainWindow.h"
Login::Login(MainWindow* mainWindow,QWidget *parent) :
    QWidget(parent),
    mw(mainWindow),
    ui(new Ui::Login)
{
    ui->setupUi(this);
}

Login::~Login()
{
    delete ui;
}

void Login::on_loginin_clicked()
{
    //获取用户名和密码
    shared_ptr<ServerMsg::LoginMsg> LoginMsgPtr = std::make_shared<ServerMsg::LoginMsg>();
    LoginMsgPtr->set_usr(ui->usr->text().toStdString());
    LoginMsgPtr->set_pwd(ui->pwd->text().toStdString());
    //连接服务器
    std::thread t1(&MainWindow::connectSrv,mw,LoginMsgPtr);
    //将该线程丢给操作系统管理
    t1.detach();
}
